<?php

/**
 * Modifies the YouTube table so it can take a YouTube url instead of a video ID
 *
 */
class Db_011_bbce_modify_plugins extends Ot_Migrate_Migration_Abstract
{
    public function up($dba)
    {
        $query = "
            CREATE TABLE `" . $this->tablePrefix . "tbl_plugin_slide` (
                `pluginName` VARCHAR( 128 ) NOT NULL ,
                `status` ENUM( 'enabled', 'disabled' ) NOT NULL ,
                PRIMARY KEY ( `pluginName` )
                ) ENGINE = InnoDB;
                
            CREATE TABLE `" . $this->tablePrefix . "tbl_plugin_slidestream` (
                `pluginName` VARCHAR( 128 ) NOT NULL ,
                `status` ENUM( 'enabled', 'disabled' ) NOT NULL ,
                PRIMARY KEY ( `pluginName` )
                ) ENGINE = InnoDB;       

            DROP TABLE `" . $this->tablePrefix . "tbl_plugin_option`, 
                `" . $this->tablePrefix . "tbl_plugin_slideoption_impression`, 
                `" . $this->tablePrefix . "tbl_plugin_slideoption_schedule`, 
                `" . $this->tablePrefix . "tbl_plugin_slideoption_transition`, 
                `" . $this->tablePrefix . "tbl_plugin_slidestreamoption_marquee`;
                
            CREATE TABLE `" . $this->tablePrefix . "tbl_plugin_slide_data` (
                `slideId` INT UNSIGNED NOT NULL ,
                `data` TEXT NOT NULL ,
                PRIMARY KEY ( `slideId` )
                ) ENGINE = InnoDB;
                
            CREATE TABLE `" . $this->tablePrefix . "tbl_plugin_slidestream_data` (
                `slidestreamId` INT UNSIGNED NOT NULL ,
                `data` TEXT NOT NULL ,
                PRIMARY KEY ( `slidestreamId` )
                ) ENGINE = InnoDB;
                
            RENAME TABLE `" . $this->tablePrefix . "tbl_plugin_slide`  TO `" . $this->tablePrefix . "tbl_slide_plugin`;
            
            RENAME TABLE `" . $this->tablePrefix . "tbl_plugin_slidestream`  TO `" . $this->tablePrefix . "tbl_slidestream_plugin`;
            
            RENAME TABLE `" . $this->tablePrefix . "tbl_plugin_slide_data`  TO `" . $this->tablePrefix . "tbl_slide_plugin_data`;
            
            RENAME TABLE `" . $this->tablePrefix . "tbl_plugin_slidestream_data`  TO `" . $this->tablePrefix . "tbl_slidestream_plugin_data`;
            
            RENAME TABLE `" . $this->tablePrefix . "tbl_slide_stream`  TO `" . $this->tablePrefix . "tbl_slidestream`;
            
            RENAME TABLE `" . $this->tablePrefix . "tbl_slide_stream_map`  TO `" . $this->tablePrefix . "tbl_slidestream_slide`;
            
            ALTER TABLE `" . $this->tablePrefix . "tbl_slidestream` CHANGE `slideStreamId` `slidestreamId` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT; 
            
            ALTER TABLE `" . $this->tablePrefix . "tbl_slidestream_slide` CHANGE `slideStreamMapId` `slidestreamSlideId` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT , 
                CHANGE `slideStreamId` `slidestreamId` INT( 10 ) UNSIGNED NOT NULL ,
                CHANGE `entityType` `entityType` ENUM( 'slide', 'slidestream' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

        ";
        
        $dba->query($query);
    }

    public function down($dba) {
        
    }    
}